home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Resources / Online / Miami / MiamiSDK / netinclude / netinet / ip.h < prev    next >
C/C++ Source or Header  |  1997-12-04  |  4KB  |  156 lines

  1. #ifndef _NETINET_IP_H_
  2. #define _NETINET_IP_H_
  3.  
  4. #ifndef _SYS_TYPES_H_
  5. #include <sys/types.h>
  6. #endif
  7.  
  8. #ifndef _MACHINE_ENDIAN_H_
  9. #include <machine/endian.h>
  10. #endif
  11.  
  12. #ifndef _NETINET_IN_H_
  13. #include <netinet/in.h>
  14. #endif
  15.  
  16. #ifndef _NETINET_IN_SYSTM_H_
  17. #include <netinet/in_systm.h>
  18. #endif
  19.  
  20. /*
  21.  * Definitions for internet protocol version 4.
  22.  * Per RFC 791, September 1981.
  23.  */
  24. #define    IPVERSION    4
  25.  
  26. /*
  27.  * Structure of an internet header, naked of options.
  28.  *
  29.  * We declare ip_len and ip_off to be short, rather than u_short
  30.  * pragmatically since otherwise unsigned comparisons can result
  31.  * against negative integers quite easily, and fail in subtle ways.
  32.  */
  33. struct ip {
  34. #if BYTE_ORDER == LITTLE_ENDIAN
  35.     u_char    ip_hl:4,        /* header length */
  36.         ip_v:4;            /* version */
  37. #endif
  38. #if BYTE_ORDER == BIG_ENDIAN
  39.     u_char    ip_v:4,            /* version */
  40.         ip_hl:4;        /* header length */
  41. #endif
  42.     u_char    ip_tos;            /* type of service */
  43.     short    ip_len;            /* total length */
  44.     u_short    ip_id;            /* identification */
  45.     short    ip_off;            /* fragment offset field */
  46. #define    IP_DF 0x4000            /* dont fragment flag */
  47. #define    IP_MF 0x2000            /* more fragments flag */
  48. #define    IP_OFFMASK 0x1fff        /* mask for fragmenting bits */
  49.     u_char    ip_ttl;            /* time to live */
  50.     u_char    ip_p;            /* protocol */
  51.     u_short    ip_sum;            /* checksum */
  52.     struct    in_addr ip_src,ip_dst;    /* source and dest address */
  53. };
  54.  
  55. #define    IP_MAXPACKET    65535        /* maximum packet size */
  56.  
  57. /*
  58.  * Definitions for IP type of service (ip_tos)
  59.  */
  60. #define    IPTOS_LOWDELAY        0x10
  61. #define    IPTOS_THROUGHPUT    0x08
  62. #define    IPTOS_RELIABILITY    0x04
  63. #define    IPTOS_MINCOST        0x02
  64.  
  65. /*
  66.  * Definitions for IP precedence (also in ip_tos) (hopefully unused)
  67.  */
  68. #define    IPTOS_PREC_NETCONTROL        0xe0
  69. #define    IPTOS_PREC_INTERNETCONTROL    0xc0
  70. #define    IPTOS_PREC_CRITIC_ECP        0xa0
  71. #define    IPTOS_PREC_FLASHOVERRIDE    0x80
  72. #define    IPTOS_PREC_FLASH        0x60
  73. #define    IPTOS_PREC_IMMEDIATE        0x40
  74. #define    IPTOS_PREC_PRIORITY        0x20
  75. #define    IPTOS_PREC_ROUTINE        0x00
  76.  
  77. /*
  78.  * Definitions for options.
  79.  */
  80. #define    IPOPT_COPIED(o)        ((o)&0x80)
  81. #define    IPOPT_CLASS(o)        ((o)&0x60)
  82. #define    IPOPT_NUMBER(o)        ((o)&0x1f)
  83.  
  84. #define    IPOPT_CONTROL        0x00
  85. #define    IPOPT_RESERVED1        0x20
  86. #define    IPOPT_DEBMEAS        0x40
  87. #define    IPOPT_RESERVED2        0x60
  88.  
  89. #define    IPOPT_EOL        0        /* end of option list */
  90. #define    IPOPT_NOP        1        /* no operation */
  91.  
  92. #define    IPOPT_RR        7        /* record packet route */
  93. #define    IPOPT_TS        68        /* timestamp */
  94. #define    IPOPT_SECURITY        130        /* provide s,c,h,tcc */
  95. #define    IPOPT_LSRR        131        /* loose source route */
  96. #define    IPOPT_SATID        136        /* satnet id */
  97. #define    IPOPT_SSRR        137        /* strict source route */
  98.  
  99. /*
  100.  * Offsets to fields in options other than EOL and NOP.
  101.  */
  102. #define    IPOPT_OPTVAL        0        /* option ID */
  103. #define    IPOPT_OLEN        1        /* option length */
  104. #define IPOPT_OFFSET        2        /* offset within option */
  105. #define    IPOPT_MINOFF        4        /* min value of above */
  106.  
  107. /*
  108.  * Time stamp option structure.
  109.  */
  110. struct    ip_timestamp {
  111.     u_char    ipt_code;        /* IPOPT_TS */
  112.     u_char    ipt_len;        /* size of structure (variable) */
  113.     u_char    ipt_ptr;        /* index of current entry */
  114. #if BYTE_ORDER == LITTLE_ENDIAN
  115.     u_char    ipt_flg:4,        /* flags, see below */
  116.         ipt_oflw:4;        /* overflow counter */
  117. #endif
  118. #if BYTE_ORDER == BIG_ENDIAN
  119.     u_char    ipt_oflw:4,        /* overflow counter */
  120.         ipt_flg:4;        /* flags, see below */
  121. #endif
  122.     union ipt_timestamp {
  123.         n_long    ipt_time[1];
  124.         struct    ipt_ta {
  125.             struct in_addr ipt_addr;
  126.             n_long ipt_time;
  127.         } ipt_ta[1];
  128.     } ipt_timestamp;
  129. };
  130.  
  131. /* flag bits for ipt_flg */
  132. #define    IPOPT_TS_TSONLY        0        /* timestamps only */
  133. #define    IPOPT_TS_TSANDADDR    1        /* timestamps and addresses */
  134. #define    IPOPT_TS_PRESPEC    3        /* specified modules only */
  135.  
  136. /* bits for security (not byte swapped) */
  137. #define    IPOPT_SECUR_UNCLASS    0x0000
  138. #define    IPOPT_SECUR_CONFID    0xf135
  139. #define    IPOPT_SECUR_EFTO    0x789a
  140. #define    IPOPT_SECUR_MMMM    0xbc4d
  141. #define    IPOPT_SECUR_RESTR    0xaf13
  142. #define    IPOPT_SECUR_SECRET    0xd788
  143. #define    IPOPT_SECUR_TOPSECRET    0x6bc5
  144.  
  145. /*
  146.  * Internet implementation parameters.
  147.  */
  148. #define    MAXTTL        255        /* maximum time to live (seconds) */
  149. #define    IPDEFTTL    64        /* default ttl, from RFC 1340 */
  150. #define    IPFRAGTTL    60        /* time to live for frags, slowhz */
  151. #define    IPTTLDEC    1        /* subtracted when forwarding */
  152.  
  153. #define    IP_MSS        576        /* default maximum segment size */
  154.  
  155. #endif
  156.